﻿namespace Vdc.Grid
{
    using Vdc.Grid.Design;
    using System;
    using System.ComponentModel;
    using System.Web.UI.WebControls;

    [TypeConverter(typeof(GridScrollingSettingsConverter))]
    public class GridScrollingSettings : GridPersistentObject, ICloneable
    {
        public object Clone()
        {
            return new GridScrollingSettings { FixedColumnsPosition = this.FixedColumnsPosition, NumberOfFixedColumns = this.NumberOfFixedColumns, ScrollHeight = this.ScrollHeight, ScrollLeft = this.ScrollLeft, ScrollTop = this.ScrollTop, ScrollWidth = this.ScrollWidth, EnableVirtualScrolling = this.EnableVirtualScrolling, UsePagingForVirtualScrolling = this.UsePagingForVirtualScrolling };
        }

        public virtual bool Equals(GridScrollingSettings settings)
        {
            return (((!(this.ScrollHeight != settings.ScrollHeight) && !(this.ScrollWidth != settings.ScrollWidth)) && ((this.NumberOfFixedColumns == settings.NumberOfFixedColumns) && (this.FixedColumnsPosition == settings.FixedColumnsPosition))) && ((this.EnableVirtualScrolling == settings.EnableVirtualScrolling) && (this.UsePagingForVirtualScrolling == settings.UsePagingForVirtualScrolling)));
        }

        object ICloneable.Clone()
        {
            return this.Clone();
        }

        [Description("Gets or sets a property indicating whether the virtual scrolling feature is enabled."), Category("Scrolling"), DefaultValue(false), Bindable(true)]
        public bool EnableVirtualScrolling
        {
            get
            {
                object obj2 = this.ViewState["EnableVirtualScrolling"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                this.ViewState["EnableVirtualScrolling"] = value;
            }
        }

        [Category("Scrolling"), Description("The position of the fixed columns (left/right)."), Bindable(true), DefaultValue(1)]
        public GridFixedColumnsPositionType FixedColumnsPosition
        {
            get
            {
                object obj2 = this.ViewState["FixedColumnsPosition"];
                if (obj2 != null)
                {
                    return (GridFixedColumnsPositionType) obj2;
                }
                return GridFixedColumnsPositionType.Left;
            }
            set
            {
                this.ViewState["FixedColumnsPosition"] = value;
            }
        }

        [Description("The number of freezed (fixed) columns."), Bindable(true), Category("Scrolling"), DefaultValue(0)]
        public int NumberOfFixedColumns
        {
            get
            {
                object obj2 = this.ViewState["NumberOfFixedColumns"];
                if (obj2 != null)
                {
                    return (int) obj2;
                }
                return 0;
            }
            set
            {
                this.ViewState["NumberOfFixedColumns"] = value;
            }
        }

        [Category("Scrolling"), NotifyParentProperty(true), Description("The height for the body containing the records."), DefaultValue(typeof(Unit), "0px"), Bindable(true)]
        public Unit ScrollHeight
        {
            get
            {
                object obj2 = base.ViewState["ScrollHeight"];
                if (obj2 != null)
                {
                    return (Unit) obj2;
                }
                return Unit.Pixel(0);
            }
            set
            {
                base.ViewState["ScrollHeight"] = value;
            }
        }

        [Bindable(true), Description("The number of pixels that will be used to scroll the Grid horizontally."), Category("Scrolling"), DefaultValue(0)]
        public int ScrollLeft
        {
            get
            {
                object obj2 = this.ViewState["ScrollLeft"];
                if (obj2 != null)
                {
                    return (int) obj2;
                }
                return 0;
            }
            set
            {
                this.ViewState["ScrollLeft"] = value;
            }
        }

        [Category("Scrolling"), Description("The number of pixels that will be used to scroll the Grid vertically."), DefaultValue(0), Bindable(true)]
        public int ScrollTop
        {
            get
            {
                object obj2 = this.ViewState["ScrollTop"];
                if (obj2 != null)
                {
                    return (int) obj2;
                }
                return 0;
            }
            set
            {
                this.ViewState["ScrollTop"] = value;
            }
        }

        [Category("Scrolling"), Bindable(true), DefaultValue(typeof(Unit), "0px"), Description("The width for the body containing the records.")]
        public Unit ScrollWidth
        {
            get
            {
                object obj2 = this.ViewState["ScrollWidth"];
                if (obj2 != null)
                {
                    return (Unit) obj2;
                }
                return Unit.Pixel(0);
            }
            set
            {
                this.ViewState["ScrollWidth"] = value;
            }
        }

        [DefaultValue(false), Description("Gets or sets a property indicating whether paging will be used for the virtual scrolling feature."), Bindable(true), Category("Scrolling")]
        public bool UsePagingForVirtualScrolling
        {
            get
            {
                object obj2 = this.ViewState["UsePagingForVirtualScrolling"];
                return ((obj2 != null) && ((bool) obj2));
            }
            set
            {
                this.ViewState["UsePagingForVirtualScrolling"] = value;
            }
        }
    }
}

